﻿using System.Threading;
using Volo.Abp.DependencyInjection;

namespace Yyd.Security.Permissions
{
    public class AsyncLocalCurrentPermissionAccessor : ICurrentPermissionAccessor, ISingletonDependency
    {
        /// <summary>
        /// 
        /// </summary>
        private readonly AsyncLocal<PermissionInfo> _currentScope;


        /// <summary>
        /// 
        /// </summary>
        public PermissionInfo Current
        {
            get => _currentScope.Value;
            set => _currentScope.Value = value;
        }

        //   public PermissionInfo Current { get;  set; }
        /// <summary>
        /// 
        /// </summary>
        public AsyncLocalCurrentPermissionAccessor()
        {
            _currentScope = new AsyncLocal<PermissionInfo>();
        }
    }
}
